home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Risc World 3
/
Risc World 3.iso
/
SOFTWARE
/
ISSUE6
/
PD
/
PDF
/
pdf
/
c++
/
DocView
< prev
next >
Wrap
Text File
|
2003-02-24
|
28KB
|
934 lines
//--------------------------------------------------------------------------
//
// Copyright (c) 2002, Colin Granville
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or
// without modification, are permitted provided that the following
// conditions are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials
// provided with the distribution.
//
// * The name Colin Granville may not be used to endorse or promote
// products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
// OF THE POSSIBILITY OF SUCH DAMAGE.
//
//--------------------------------------------------------------------------
#include "DocView.h"
#include "Document.h"
#include "GuiHourglass.h"
#include "UserEvents.h"
#include "GuiScale.h"
#include "PrintDialog.h"
#include "pointer.h"
#include "GuiTask.h"
#include "UriDispatch.h"
#include "gfile.h"
#include "guilib:gfx.h"
#include "Find.h"
#include "outline.h"
//*************************************************************************
void DragWorkArea::drag(GuiWindow& win)
{
window = &win;
GuiPointerInfo info;
GuiGetWindowStateBlock ws;
win.getState(ws);
x=info.x;
y=info.y;
GuiBBox box;
win.getExtent(box);
GuiBBox extent=ws.toScreen(box);
GuiDragBox db;
db.parentBox.xmin = x-extent.xmax+ws.visibleArea.xmax;
db.parentBox.xmax = x+ws.visibleArea.xmin-extent.xmin;
db.parentBox.ymax = y+ws.visibleArea.ymin-extent.ymin;
db.parentBox.ymin = y-extent.ymax+ws.visibleArea.ymax;
db.startDrag(GuiDragBox::DragPoint);
dragEndedTarget(0,GuiWimp_EUserDrag,this,DragWorkArea::dragEnded);
nullEventTarget(this,DragWorkArea::nullEvent);
}
//*************************************************************************
void DragWorkArea::nullEvent()
{
GuiPointerInfo info;
GuiGetWindowStateBlock ws;
window->getState(ws);
if (info.x==x && info.y==y) return;
ws.yscroll+=(y-info.y);
ws.xscroll+=(x-info.x);
window->show(ws);
x=info.x;
y=info.y;
}
//*************************************************************************
Claim DragWorkArea::dragEnded(GuiWimpPollBlock&,const GuiIdBlock&)
{
nullEventTarget.destroy();
dragEndedTarget.destroy();
return CLAIM;
}
//*************************************************************************
//*************************************************************************
//*************************************************************************
//DEFINE_RTTI_DERIVED(View,Node);
DEFINE_RTTI_DERIVED(DocView,Node);
DocView::DocView(Document& doc,const DocViewChoices& choices,int page, int logicalPageOffset)
: document(0),
mainWin("mainWin"),
displayMenu("displayMenu"),
toolbar(*this,mainWin),
save(*this,mainWin),
handPointerShowing(0),
highlightIsOn(0),
closeWindowTarget(&mainWin,GuiWimp_ECloseWindow,this,DocView::closeWindow),
openWindowTarget(&mainWin,GuiWimp_EOpenWindow,this,DocView::openWindow),
redrawWindowTarget(&mainWin,GuiWimp_ERedrawWindow,this,DocView::redrawWindow),
mouseClickTarget(&mainWin,GuiWimp_EMouseClick,this,DocView::mouseClick),
pointerEnteringTarget(&mainWin,GuiWimp_EPointerEnteringWindow,this,DocView::pointerEntering),
pointerLeavingTarget(&mainWin,GuiWimp_EPointerLeavingWindow,this,DocView::pointerLeaving),
newViewTarget(&mainWin,User_NewView,this,DocView::newView),
rotateViewTarget(&mainWin,User_RotateView,this,DocView::rotateView),
printDialogOpenTarget(&mainWin,User_PrintDialogOpen,this,DocView::printDialogOpen),
displayMenuATBSTarget(&mainWin,User_DisplayMenuATBS,this,DocView::displayMenuATBS),
miscMenuATBSTarget(&mainWin,User_MiscMenuATBS,this,DocView::miscMenuATBS),
saveMenuATBSTarget(&mainWin,User_SaveMenuATBS,this,DocView::saveMenuATBS),
highlightLinksTarget(&mainWin,User_HighlightLinks,this,DocView::highlightLinks),
setNoImagesTarget(&mainWin,User_SetNoImages,this,DocView::setNoImages),
setNoTextTarget(&mainWin,User_SetNoText,this,DocView::setNoText),
setNoType3FontsTarget(&mainWin,User_SetNoType3Fonts,this,DocView::setNoType3Fonts),
setNoDrawingsTarget(&mainWin,User_SetNoDrawings,this,DocView::setNoDrawings),
fileInfoATBSTarget(&mainWin,User_FileInfoATBS,this,DocView::fileInfoATBS),
scaleViewTarget(&mainWin,GuiScale::ApplyFactor::Event,this,DocView::scaleView),
scaleUpTarget(&mainWin,User_ScaleUp,this,DocView::scaleUp),
scaleDownTarget(&mainWin,User_ScaleDown,this,DocView::scaleDown),
scale100Target(&mainWin,User_Scale100,this,DocView::scale100),
scaleATBSTarget(&mainWin,GuiScale::AboutToBeShown::Event,this,DocView::scaleATBS),
saveDisplayChoicesTarget(&mainWin,User_SaveDisplayChoices,this,DocView::saveDisplayChoices),
findATBSTarget(&mainWin,User_FindATBS,this,DocView::findATBS)
{
set(doc,choices,page,logicalPageOffset);
}
DocView::~DocView()
{
find(*this,FIND_VIEW_CLOSED);
if (getParent()) getParent()->removeChild(this);
}
//*************************************************************************
void DocView::set(Document& doc,const DocViewChoices& new_choices,
int page,int logicalPageOffset,bool add_to_history)
{
toolbar.flushPendingHistory();
if (&doc!=document)
{
if (document && document!=&doc)
{
highlightIsOn=0;
find(*this,FIND_VIEW_CLOSED);
document->removeChild(this);
}
document=&doc;
document->addChild(this);
}
toolbar.setFirstPage(page,logicalPageOffset,document->getPageCount(),add_to_history);
if (&choices != &new_choices) choices=new_choices;
showPage();
scroll(SCROLL_TOP);
}
//*************************************************************************
void DocView::setPage(const DocPage& page,bool add_to_history)
{
Document* new_doc=makeDocument(*document->getParent(),page.docName.c_str());
if (new_doc) set(*new_doc,choices,page.page,toolbar.getLogicalPageOffset(),add_to_history);
}
//*************************************************************************
void DocView::transformHighlight(GuiBBox& box)
{
double factor=((double)choices.getScale())/25600.0; //scale and convert to os units
box.xmin=(int)(highlightArea.xmin*factor);
box.ymin=(int)(highlightArea.ymin*factor);
box.xmax=(int)(highlightArea.xmax*factor);
box.ymax=(int)(highlightArea.ymax*factor);
if (choices.getRotation()!=0)
{
GuiBBox paper;
mainWin.getExtent(paper);
GuiBBox toolbarBox;
toolbar.getExtent(toolbarBox);
paper.ymax-=toolbarBox.getHeight();
int x,y,wid,ht;
switch (choices.getRotation())
{
case 180:
wid = box.getWidth();
ht = box.getHeight();
x=paper.getWidth()-(box.xmin+box.xmax)/2;
y=paper.getHeight()-2-(box.ymin+box.ymax)/2;
break;
case 270:
wid = box.getHeight();
ht = box.getWidth();
y=-2+(box.xmin+box.xmax)/2;
x=paper.getWidth()-(box.ymin+box.ymax)/2;
break;
default:
wid = box.getHeight();
ht = box.getWidth();
y=-2+paper.getHeight()-(box.xmin+box.xmax)/2;
x=(box.ymin+box.ymax)/2;
}
box.xmax=x+wid/2;
box.ymax=y+ht/2;
box.xmin=box.xmax-wid;
box.ymin=box.ymax-ht;
}
}
//*************************************************************************
void DocView::setHighlight(int pageNum,HighlightBBox& box)
{
bool changedPage=(pageNum!=toolbar.getPage());
if (!changedPage) clearHighlight();
highlightArea=box;
highlightIsOn=1;
if (changedPage) toolbar.setPage(pageNum);
GuiBBox highlight;
transformHighlight(highlight);
GuiGetWindowStateBlock ws;
mainWin.getState(ws);
GuiBBox visibleArea=ws.toWorkarea(ws.visibleArea);
int xscroll=0;
int yscroll=0;
int d=32;
int topd=96;
if (highlight.xmin<visibleArea.xmin)
xscroll=highlight.xmin-visibleArea.xmin-d;
else if (highlight.xmax>visibleArea.xmax)
xscroll= highlight.xmax-visibleArea.xmax+d;
if ( (xscroll || changedPage) && highlight.xmax < visibleArea.getWidth())
xscroll=-visibleArea.xmin;
if (highlight.ymin<visibleArea.ymin)
yscroll=highlight.ymin-visibleArea.ymin-d;
else if (highlight.ymax>visibleArea.ymax-topd)
yscroll=highlight.ymax-visibleArea.ymax+topd;
if (xscroll!=0 || yscroll!=0)
{
ws.xscroll+=xscroll;
ws.yscroll+=yscroll;
mainWin.show(ws);
}
if (!changedPage)
{
highlight.xmax+=4;
highlight.ymax+=4;
mainWin.forceRedraw(highlight);
}
}
//*************************************************************************
void DocView::clearHighlight()
{
if (highlightIsOn)
{
GuiBBox highlight;
transformHighlight(highlight);
highlight.xmax+=4;
highlight.ymax+=4;
mainWin.forceRedraw(highlight);
highlightIsOn=0;
}
}
//*************************************************************************
void DocView::showPage()
{
GuiHourglass hg;
outDev.setNoImages(choices.getNoImages());
outDev.setNoText(choices.getNoText());
outDev.setNoType3Fonts(choices.getNoType3Fonts());
outDev.setNoDrawings(choices.getNoDrawings());
document->getPage(toolbar.getPage(),&outDev,DrawOutputDevice::DPI,choices.getRotation());
Scale(Scale());
links.reset(document->makeLinks(toolbar.getPage()));
nullEvent();
}
//*************************************************************************
void DocView::Redraw(int)
{
GuiBBox box;
mainWin.getExtent(box);
mainWin.forceRedraw(box);
}
//*************************************************************************
void DocView::Scale(int percent)
{
static int off=3;
choices.setScale(percent);
GuiTransform trfm;
trfm.m0 = (percent << 16) / 100; trfm.m1 = 0;
trfm.m2 = 0; trfm.m3 = trfm.m0;
trfm.m4 = 0; trfm.m5 = 0;
GuiBBox bounds;
outDev.getDrawFile().getBBox(bounds,&trfm);
if (bounds.getWidth() < 640*256)
{
//scale to minimum width
int wid = bounds.getWidth();
if (wid<80*256) wid=80*256;
choices.setScale(((percent*640*256)/wid)+1);
trfm.m0 = (Scale() << 16) / 100;
trfm.m3 = trfm.m0;
outDev.getDrawFile().getBBox(bounds,&trfm);
}
GuiBBox ex;
ex(0,0,bounds.xmax/256,bounds.ymax/256);
{
GuiBBox box;
toolbar.getExtent(box);
ex.ymax+=box.getHeight();
}
mainWin.setExtent(ex);
if (!mainWin.isShowing())
{
mainWin.showCentred(-off*36,off*36);
if (--off<0) off=3;
}
else
{
mainWin.forceRedraw(ex);
}
GuiGetWindowStateBlock ws;
mainWin.getState(ws);
// ws.yscroll=ex.ymax;
openWindow((GuiWimpPollBlock&)ws,guiTask().idBlock());
}
//*************************************************************************
int DocView::Scale()
{
return choices.getScale();
}
//*************************************************************************
bool DocView::scroll(ScrollType mode)
{
GuiGetWindowStateBlock state;
toolbar.getState(state);
int distance=-state.visibleArea.getHeight()-32;
mainWin.getState(state);
distance += state.visibleArea.getHeight();
int yscroll=state.yscroll;
state.yscroll+=(mode==SCROLL_DOWN? -distance: distance);
if (mode==SCROLL_BOTTOM || mode==SCROLL_TOP)
{
GuiBBox box;
mainWin.getExtent(box);
if (mode==SCROLL_BOTTOM) state.yscroll=box.ymin;
if (mode==SCROLL_TOP) state.yscroll=box.ymax;
}
mainWin.show(state);
mainWin.getState(state);
return yscroll!=state.yscroll;
}
//*************************************************************************
Claim DocView::closeWindow(GuiWimpPollBlock&,const GuiIdBlock&)
{
GuiPointerInfo info;
if (info.buttons & GuiPointerInfo::Adjust)
{
int shift=gfx::inkey(-1);
size_t n=document->getFileName().rfind('.');
if (n!=string::npos)
{
string s="filer_opendir ";
s+=document->getFileName().substr(0,n);
_swix(OS_CLI,_IN(0),s.c_str());
if (shift) return CLAIM;
}
}
delete this;
return CLAIM;
};
//*************************************************************************
Claim DocView::openWindow(GuiWimpPollBlock& wpb,const GuiIdBlock&)
{
GuiOpenWindowBlock& block=wpb.openWindowRequest;
int behind=block.behind;
block.behind=block.windowHandle;
mainWin.show(block);
mainWin.getState(block);
if (behind!=-1 && block.behind==-1) behind=-1;
block.behind=behind;
toolbar.openWindow(mainWin,block);
mainWin.show(block);
return CLAIM;
};
//*************************************************************************
Claim DocView::redrawWindow(GuiWimpPollBlock& wpb,const GuiIdBlock&)
{
static int fontBlend=2;
if (fontBlend==2)
{
fontBlend=(getenv("PDF$NoFontBlending")==0);
}
bool more;
GuiRedrawWindowBlock& block=wpb.redrawWindowRequest;
GuiTransform trfm;
trfm.m0 = (choices.getScale() << 16) / 100; trfm.m1 = 0;
trfm.m2 = 0; trfm.m3 = trfm.m0;
GuiBBox highlight;
if (highlightIsOn) transformHighlight(highlight);
for (GuiWindow::redraw(block,more);more;GuiWindow::getRectangle(block,more))
{
trfm.m4 = block.xToScreen(0)*256;
trfm.m5 = block.yToScreen(0)*256+128;
outDev.getDrawFile().render(&trfm,&block.redrawArea,fontBlend);
if (fontBlend && choices.getHighlightLinks() && links.get())
{
// highlight links if drawing to screen
// use fontBlend to tell if it is to screen as
// font blending only works on the screen
double xa1,ya1,xa2,ya2,width;
int x1,y1,x2,y2;
int i;
for (i=0;i<links->getNumLinks();i++)
{
Link* link=links->getLink(i);
if (!link) continue;
link->getBorder(&xa1,&ya1,&xa2,&ya2,&width);
outDev.cvtUserToDev(xa1,ya1,&x1,&y1);
outDev.cvtUserToDev(xa2,ya2,&x2,&y2);
x1=(x1*choices.getScale())/25600;
y1=(y1*choices.getScale())/25600;
x2=(x2*choices.getScale())/25600;
y2=(y2*choices.getScale())/25600;
if (x2<x1) {int temp=x1;x1=x2;x2=temp;}
if (y2<y1) {int temp=y1;y1=y2;y2=temp;}
gfx::gcol_bgr(1,0xb0000000);
gfx::rectanglefill(block.xToScreen(x1),block.yToScreen(y1),x2-x1,y2-y1);
}
}
if (highlightIsOn)
{
int x=trfm.m4/256;
int y=trfm.m5/256;
gfx::move(x+highlight.xmin,y+highlight.ymin);
gfx::plot(gfx::RectangleFill | gfx::DrawAbsInverse,
x+highlight.xmax,y+highlight.ymax);
}
}
return CLAIM;
}
//*************************************************************************
Claim DocView::mouseClick(GuiWimpPollBlock& wpb,const GuiIdBlock&)
{
if ((wpb.mouseClick.buttons & GuiPointerInfo::Menu) == 0)toolbar.setFocus();
if (!links.get() || (wpb.mouseClick.buttons & GuiPointerInfo::Menu)) return CLAIM;
GuiGetWindowStateBlock ws;
mainWin.getState(ws);
int x=ws.xToWorkarea(wpb.mouseClick.x)*256;
int y=ws.yToWorkarea(wpb.mouseClick.y)*256;
x=(x*100)/choices.getScale();
y=(y*100)/choices.getScale();
double user_x,user_y;
outDev.cvtDevToUser(x,y,&user_x,&user_y);
LinkAction* action=links->find(user_x,user_y);
if (action==0)
{
dragView.drag(mainWin);
return CLAIM;
}
doAction(action,wpb.mouseClick.buttons & GuiPointerInfo::Adjust);
return CLAIM;
}
//*************************************************************************
void DocView::doAction(LinkAction* action,bool adjust)
{
switch (action->getKind())
{
case actionGoTo:
{
LinkGoTo& go = *(LinkGoTo*)action;
LinkDest* dest=go.getDest();
if (!dest) dest=document->findDest(go.getNamedDest());
if (!dest || !dest->isOk()) break;
int page=dest->getPageNum();
if (dest->isPageRef()) page=document->findPage(dest->getPageRef());
if (adjust)
makeDocView(document,choices,page,toolbar.getLogicalPageOffset());
else
set(*document,choices,page,toolbar.getLogicalPageOffset());
break;
}
case actionGoToR:
{
LinkGoToR& go = *(LinkGoToR*)action;
char* s = go.getFileName()->getCString();
auto_ptr<GString> file_name;
if (isAbsolutePath(s))
file_name.reset(new GString(s));
else
file_name.reset(appendToPath(grabPath((char*)document->getFileName().c_str()), s));
if (!file_name.get()) break;
int page=0;
LinkDest* dest=go.getDest();
if (dest && dest->isOk())
{
page=dest->getPageNum();
if (dest->isPageRef()) page=document->findPage(dest->getPageRef());
}
Document* new_doc=makeDocument(*document->getParent(),file_name->getCString());
if (!new_doc) break;
if (!dest)
{
dest=new_doc->findDest(go.getNamedDest());
if (dest && dest->isOk())
{
page=dest->getPageNum();
if (dest->isPageRef()) page=new_doc->findPage(dest->getPageRef());
}
}
if (adjust)
makeDocView(new_doc,choices,page);
else
set(*new_doc,choices,page);
break;
}
case actionURI:
{
string uri= ((LinkURI*)action)->getURI()->getCString();
dispatch_uri(uri);
break;
}
case actionLaunch:
{
char* s = ((LinkLaunch*)action)->getFileName()->getCString();
char* ext = s+((LinkLaunch*)action)->getFileName()->getLength()-4;
if (!( ext>s && (strcmp(ext, ".pdf") || strcmp(ext, ".PDF")))) break;
auto_ptr<GString> file_name;
if (isAbsolutePath(s))
file_name.reset(new GString(s));
else
file_name.reset(appendToPath(grabPath((char*)document->getFileName().c_str()), s));
if (!file_name.get()) break;
Document* new_doc=makeDocument(*document->getParent(),file_name->getCString());
if (!new_doc) break;
if (adjust)
makeDocView(new_doc,choices,1);
else
set(*new_doc,choices,1);
break;
}
case actionNamed:
{
GString* name = ((LinkNamed*)action)->getName();
int page=0;
if (name->cmp("NextPage")==0) {if (getPage()<document->getPageCount()) page=getPage()+1;}
else if (name->cmp("PrevPage")==0) page=getPage()-1;
else if (name->cmp("FirstPage")==0) page=1;
else if (name->cmp("LastPage")==0) page=document->getPageCount();
else if (name->cmp("GoBack")==0)
{
toolbar.goBack();
}
else if (name->cmp("ShowHideBookmarks")==0)
{
Outline* o=getDocument().getOutline();
if (o) o->open(*this);
}
else if (name->cmp("Find")==0 || name->cmp("FindAgain")==0)
{
GuiWindow f("Find");
f.showCentred(0,0,&mainWin,&mainWin);
}
else if (name->cmp("Print")==0)
{
if (document->getPDFDoc().okToPrint()) PrintDialog_open(*this,mainWin,toolbar.getPage());
}
if (page)
{
if (adjust)
makeDocView(document,choices,page);
else
set(*document,choices,page);
}
break;
}
case actionUnknown: break;
}
}
//*************************************************************************
void DocView::setHandPointer(bool hand)
{
if (hand)
{
if (!handPointerShowing) setPointer("ptr_hand",6,0,guiTask().spriteArea());
handPointerShowing=1;
}
else
{
if (handPointerShowing) setPointer("ptr_default");
handPointerShowing=0;
}
}
//*************************************************************************
Claim DocView::pointerEntering(GuiWimpPollBlock&,const GuiIdBlock&)
{
nullEventTarget(this,DocView::nullEvent,25);
return CLAIM;
}
//*************************************************************************
Claim DocView::pointerLeaving(GuiWimpPollBlock&,const GuiIdBlock&)
{
nullEventTarget.destroy();
setHandPointer(0);
return CLAIM;
}
//*************************************************************************
void DocView::nullEvent()
{
if (!links.get())
{
setHandPointer(0);
return;
}
GuiPointerInfo info;
GuiGetWindowStateBlock ws;
mainWin.getState(ws);
if (info.windowHandle!=ws.windowHandle) return; //necessary because nullEvent is called on page change
int x=ws.xToWorkarea(info.x)*256;
int y=ws.yToWorkarea(info.y)*256;;
x=(x*100)/choices.getScale();
y=(y*100)/choices.getScale();
double user_x,user_y;
outDev.cvtDevToUser(x,y,&user_x,&user_y);
setHandPointer(links->find(user_x,user_y) != 0);
}
//*************************************************************************
Claim DocView::newView(GuiToolboxEvent&,const GuiIdBlock&)
{
makeDocView(document,choices,toolbar.getPage(),toolbar.getLogicalPageOffset());
return CLAIM;
}
//*************************************************************************
Claim DocView::rotateView(GuiToolboxEvent&,const GuiIdBlock& id_block)
{
int rot=choices.getRotation();
switch (id_block.self.component)
{
case 0: rot=0;break;
case 1: rot=270;break;
case 2: rot=180;break;
case 3: rot=90;break;
}
if (choices.getRotation()!=rot)
{
choices.setRotation(rot);
showPage();
}
return CLAIM;
}
//*************************************************************************
Claim DocView::printDialogOpen(GuiToolboxEvent&,const GuiIdBlock&)
{
if (document->getPDFDoc().okToPrint()) PrintDialog_open(*this,mainWin,toolbar.getPage());
return CLAIM;
}
//*************************************************************************
Claim DocView::displayMenuATBS(GuiToolboxEvent&,const GuiIdBlock&)
{
displayMenu.entryTick(2,choices.getHighlightLinks());
displayMenu.entryTick(3,choices.getNoImages());
displayMenu.entryTick(5,choices.getNoText());
displayMenu.entryTick(6,choices.getNoType3Fonts());
displayMenu.entryTick(7,choices.getNoDrawings());
return CLAIM;
}
//*************************************************************************
Claim DocView::miscMenuATBS(GuiToolboxEvent&,const GuiIdBlock&)
{
GuiMenu menu("miscMenu");
menu.entryFade(3,!document->getPDFDoc().okToPrint());
return CLAIM;
}
//*************************************************************************
Claim DocView::saveMenuATBS(GuiToolboxEvent&,const GuiIdBlock&)
{
GuiMenu menu("saveMenu");
menu.entryFade(1,!document->getPDFDoc().okToCopy());
menu.entryFade(3,!document->getPDFDoc().okToCopy());
menu.entryFade(6,!document->getPDFDoc().okToPrint());
menu.entryFade(2,!document->getPDFDoc().okToPrint());
menu.entryFade(4,!document->getPDFDoc().okToCopy());
menu.entryFade(5,!document->getPDFDoc().okToCopy());
return CLAIM;
}
//*************************************************************************
Claim DocView::highlightLinks(GuiToolboxEvent&,const GuiIdBlock&)
{
choices.setHighlightLinks(!choices.getHighlightLinks());
displayMenu.entryTick(2,choices.getHighlightLinks());
showPage();
return CLAIM;
}
//*************************************************************************
Claim DocView::setNoImages(GuiToolboxEvent&,const GuiIdBlock&)
{
choices.setNoImages(!choices.getNoImages());
displayMenu.entryTick(3,choices.getNoImages());
showPage();
return CLAIM;
}
//*************************************************************************
Claim DocView::setNoText(GuiToolboxEvent&,const GuiIdBlock&)
{
choices.setNoText(!choices.getNoText());
displayMenu.entryTick(5,choices.getNoText());
showPage();
return CLAIM;
}
//*************************************************************************
Claim DocView::setNoType3Fonts(GuiToolboxEvent&,const GuiIdBlock&)
{
choices.setNoType3Fonts(!choices.getNoType3Fonts());
displayMenu.entryTick(6,choices.getNoType3Fonts());
showPage();
return CLAIM;
}
//*************************************************************************
Claim DocView::setNoDrawings(GuiToolboxEvent&,const GuiIdBlock&)
{
choices.setNoDrawings(!choices.getNoDrawings());
displayMenu.entryTick(7,choices.getNoDrawings());
showPage();
return CLAIM;
}
//*************************************************************************
Claim DocView::fileInfoATBS(GuiToolboxEvent&,const GuiIdBlock&)
{
FileInfo_ATBS(document->getFileInfoData());
return CLAIM;
}
//*************************************************************************
Claim DocView::scaleView(GuiToolboxEvent& ev,const GuiIdBlock&)
{
GuiScale::ApplyFactor& af=(GuiScale::ApplyFactor&)ev;
if (choices.getScale()!=af.factor)
{
choices.setScale(af.factor);
Scale(Scale());
}
return CLAIM;
}
//*************************************************************************
Claim DocView::scaleUp(GuiToolboxEvent&,const GuiIdBlock&)
{
int percent = choices.getScale();
choices.setScale((percent*14142)/10000);
if (Scale() != percent) Scale(Scale());
return CLAIM;
}
//*************************************************************************
Claim DocView::scaleDown(GuiToolboxEvent&,const GuiIdBlock&)
{
int percent = choices.getScale();
choices.setScale((percent*7071)/10000);
if (Scale() != percent) Scale(Scale());
return CLAIM;
}
//*************************************************************************
Claim DocView::scale100(GuiToolboxEvent&,const GuiIdBlock&)
{
int percent = choices.getScale();
choices.setScale(100);
if (Scale() != percent) Scale(Scale());
return CLAIM;
}
//*************************************************************************
Claim DocView::scaleATBS(GuiToolboxEvent&,const GuiIdBlock& id_block)
{
GuiScale win(id_block.self.id);
win.setValue(Scale());
return CLAIM;
}
//*************************************************************************
Claim DocView::saveDisplayChoices(GuiToolboxEvent&,const GuiIdBlock&)
{
choices.save();
return CLAIM;
}
//*************************************************************************
Claim DocView::findATBS(GuiToolboxEvent&,const GuiIdBlock&)
{
find(*this);
return CLAIM;
}
//*************************************************************************
bool makeDocView(Document* document,const DocViewChoices& choices,int page,int logicalPageOffset)
{
if (!document) return 0;
DocView* view = new DocView(*document,choices,page,logicalPageOffset);
return view!=0;
}